<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/26 0026
 * Time: 上午 12:01
 */
header("Content-type: text/html; charset=utf-8");
include 'Hook.class.php';

$hook = new Hook();
$hook->addHook('top');
$hook->addHook('main');
$hook->addHook('paramTest');
$hook->addHook('bottom');

$hook->addCallBack('top', 'topTest');
$hook->addCallBack('main', 'mainTest');
$hook->addCallBack('paramTest', 'paramTest');
$hook->addCallBack('bottom', 'bottomTest', array('para' => 'test'));//内部参数测试
$hook->addCallBack('bottom', 'bottomTest2', array('para' => 'test2'));//内外参数测试

function topTest()
{
    echo '这里是top测试！！<br/>';
}

function mainTest()
{
    echo '这里是main测试！！<br/>';
}

function bottomTest($param)
{
    echo '这里是bottom测试！！参数显示：' . $param . '。<br/>';
}

function bottomTest2($param2, $para)
{
    echo "这里是内外参数测试！！参数显示： $para $param2 。<br/>";
}

function paramTest($param)
{
    echo '这里是外部参数测试：' . $param . '。<br/>';
}

echo '<h1>这是HOOK测试！！</h1>';


$hook->runhook('top');
$hook->runhook('main');
$hook->runhook('paramTest', array('test' => 'test', 'test2' => 'test2'));//外部参数测试
$hook->runhook('bottom', '123');

echo '<h1>这是删除后的测试！！</h1><br/>';

$hook->delHook('bottom');//删除位置

$hook->runhook('top');
$hook->runhook('main');
$hook->runhook('paramTest', array('test' => 'test', 'test2' => 'test2'));//外部参数测试
$hook->runhook('bottom', '123');